/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Client;
import java.net.*;
import java.lang.String;
import java.awt.*;
import java.awt.Event;
import javax.swing.*;
import com.google.gson.Gson;
/**
 *
 * @author j_sno
 */
public class SendRequest {



        public int RqNo;
        public String Name;
        public String ipAddress;
        public int port;
        public String Reason;




public void SendRequest()throws Exception{

DatagramSocket socket;
DatagramPacket packet;
InetAddress address;
Gson gson = new Gson();
Message testobj = new Message();
String decoded = gson.toJson(testobj);



byte[] message2 = new byte[100];
byte[] message = decoded.getBytes("UTF-8");
System.out.println(message.length);
int port1 = port;
String name = Name;
address = InetAddress.getByName(ipAddress);
socket = new DatagramSocket();
packet = new DatagramPacket(message, message.length, address, port1);
System.out.println("sending this guy ---> "+decoded +address);
socket.send(packet);
packet = new DatagramPacket(message2, message2.length);
socket.receive(packet); /* SEE NEXT SLIDE*/// TODO code application logic here
String received = new String(packet.getData(), 0);
System.out.println("Received: " + received);
socket.close();




        }
}
